/**
 *  example3_combo.vala
 *
 *  Copyright (c) 2007 Marcelo Lira dos Santos <setanta@gmail.com>
 *
 *  Author: Marcelo Lira dos Santos <setanta@gmail.com>
 *
 *  This program is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU General Public License as
 *  published by the Free Software Foundation; either version 2 of the
 *  License, or (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
 *  USA
 */

using GLib;
using Gtk;
using Pango;

namespace ValaDemo
{
    public class Example3Combo : ComboBox
    {
        construct {
            var store = new ListStore(2, typeof(Gdk.Pixbuf), typeof(string));

            var cell_pix = new CellRendererPixbuf();
            cell_pix.set_fixed_size(22, -1);
            pack_start(cell_pix, false);
            add_attribute(cell_pix, "pixbuf", 0);

            var cell_text = new CellRendererText();
            cell_text.ellipsize = EllipsizeMode.END;
            pack_start(cell_text, true);
            add_attribute(cell_text, "markup", 1);

            GLib.Error error;
            var path = "/usr/share/icons/Tango/22x22/emotes/";
            var pixbuf1 = Gdk.Pixbuf.from_file(path + "face-angel.png", ref error);
            var pixbuf2 = Gdk.Pixbuf.from_file(path + "face-grin.png", ref error);
            var pixbuf3 = Gdk.Pixbuf.from_file(path + "face-monkey.png", ref error);

            TreeIter treeIter;
            store.append(ref treeIter);
            store.set(ref treeIter, 0, pixbuf1, 1, "Item 1", -1);
            store.append(ref treeIter);
            store.set(ref treeIter, 0, pixbuf2, 1, "Item 2", -1);
            store.append(ref treeIter);
            store.set(ref treeIter, 0, pixbuf3, 1, "Item 3", -1);

            set_model(store);
            set_active(0);
        }
    }
}
